package DataStructures.mySort;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @Author: yqy
 * @Date: 2022/06/07/21:34
 * @Description:
 */
public class Bubble {
    public static int[] bubble(int[] arr){
        boolean flag=false;
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if (arr[j]>arr[j+1]){
                    flag=true;
                    int temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }
        if (!flag){
            return arr;
        }else {
            flag=false;
        }
        return arr;
    }
}
